package com.Analyzer;

import java.io.CharArrayReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class Analyzer {
	static IKSegmenter ikSegmenter = new IKSegmenter(new CharArrayReader(
			"init".toCharArray()), true);

	public static List<String> analyze(String targetStr) {
		ArrayList<String> resultList = new ArrayList<String>();

		ikSegmenter.reset(new CharArrayReader(targetStr.toCharArray()));

		Lexeme lexeme = null;
		try {
			for (lexeme = ikSegmenter.next(); (lexeme != null)
					&& (lexeme.getEndPosition() <= targetStr.length()); lexeme = ikSegmenter
					.next()) {
				
				resultList.add(lexeme.getLexemeText());
			}
		} catch (IOException e) {
			resultList=null;
			e.printStackTrace();
		}

		return resultList;
	}
}
